﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Install/InstallSite.Master" AutoEventWireup="true" CodeBehind="AddBookType.aspx.cs" Inherits="TeachingManageSystem.Web.Install.AddBookType" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .style1
        {
            width: 100%;
            margin-bottom: 0px;
        }
    </style>
    
   

</asp:Content>


<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    
     <script src="../Scripts/jquery-1.7.1.js" type="text/javascript"></script>
<script type="text/javascript">

    $(function () {
        $("#ContentPlaceHolder1_TbxBookTypeName").change(function () {
            $.ajax({
                type: "GET",
                url: "AddBookType.aspx/IsExsitBookTypeName",
                dataType: "text",
                data: "btName=" + $("#ContentPlaceHolder1_TbxBookTypeName").val(),
                beforeSend: function () {
                    $("#showResult").text("正在查询...");
                },
                success: function (result) {
                    if (result != "0") {
                        $("#showResult").html("已经存在类别名:" + result);
                        $("#showResult").css("color", "red");
                    }
                    else {
                        //                        $("#showResult").text("恭喜您可以插入");
                        $("#showResult").hide();
                        $("#showResult").css("color", "black");
                    }
                },
                complete: function () {
                    //隐藏正在查询图片

                },
                error: function () {
                    //错误处理
                }
            });
        });
//        $(":submit").click(function () {
//            if ($("#showResult").hide()) {
////                alert("你添加的类别名已经存在");
//                return false;
//            }
//            return true;
//        });
    });
    //   $(document).ready(function () {
    //       $(":submit").click(function () {
    //         if ($("#showResult").text != "恭喜您可以插入") {
    //                alert("你添加的类别名已经存在");
    //                return false;
    //            }
    //            return true;
    //        });
    //    });

</script>
     <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True">
                    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1"  runat="server">
        <ContentTemplate>
            <table class="style1">
        <tr>
            <td>
                <table class="style1">
                    <tr>
                        <td>
                            <asp:Label ID="Label1" runat="server" Text=" 类别名"></asp:Label> 
                        </td>
                        <td>
                            <asp:TextBox ID="TbxBookTypeName" runat="server"></asp:TextBox>
                             <div id="showResult" style="float:left"></div>
                            <br />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                ControlToValidate="TbxBookTypeName" ErrorMessage="类别名不能为空"></asp:RequiredFieldValidator>
                            <asp:TextBoxWatermarkExtender ID="TbxBookTypeName_TextBoxWatermarkExtender" 
                                runat="server" Enabled="True" TargetControlID="TbxBookTypeName" 
                                WatermarkText="请输入类别名">
                            </asp:TextBoxWatermarkExtender>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="Label2" runat="server" Text="备注"></asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="TbxBookTypeRemark" runat="server"></asp:TextBox>
                            <asp:TextBoxWatermarkExtender ID="TbxBookTypeRemark_TextBoxWatermarkExtender" 
                                runat="server" Enabled="True" TargetControlID="TbxBookTypeRemark" 
                                WatermarkText="请输入备注">
                            </asp:TextBoxWatermarkExtender>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;</td>
                        <td>
                            <asp:Button ID="BtnAdd" runat="server" onclick="BtnAddClick" Text="添加" />
                        </td>
                    </tr>
                   
                </table>
            </td>
            <td>
                <div id="showbooktypr">
                <asp:GridView ID="GridViewBookType" runat="server" Height="107px" Width="702px" 
                        EnableSortingAndPagingCallbacks="True" 
                        onrowdeleting="GridViewBookTypeRowDeleting" AutoGenerateColumns="False" 
                        EnablePersistedSelection="True" PageSize="5" DataKeyNames="ID" 
                        AllowPaging="True" onpageindexchanging="GridViewBookTypePageIndexChanging" 
                        BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" 
                        CellPadding="3" onrowcancelingedit="GridViewBookTypeRowCancelingEdit" 
                        onrowediting="GridViewBookTypeRowEditing" 
                        onrowupdating="GridViewBookTypeRowUpdating">
                    <Columns>
                        <asp:BoundField DataField="Name" HeaderText="类别名" />
                        <asp:BoundField DataField="Remark" HeaderText="备注" />
                        <asp:CommandField ShowDeleteButton="True" />
                        <asp:CommandField ShowEditButton="True" />
                    </Columns>
                    <FooterStyle BackColor="White" ForeColor="#000066" />
                    <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
                    <PagerSettings FirstPageText="首页" LastPageText="末页" NextPageText="下一页" 
                        PageButtonCount="8" PreviousPageText="上一页" />
                    <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                    <RowStyle ForeColor="#000066" />
                    <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                    <SortedAscendingCellStyle BackColor="#F1F1F1" />
                    <SortedAscendingHeaderStyle BackColor="#007DBB" />
                    <SortedDescendingCellStyle BackColor="#CAC9C9" />
                    <SortedDescendingHeaderStyle BackColor="#00547E" />
                </asp:GridView>
                    <br />
                    <br />
                </div>
            </td>
        </tr>
    </table>
        </ContentTemplate>
    </asp:UpdatePanel>
    
</asp:Content>
